package com.test.member.controller;


import com.test.common.api.CommonResult;
import com.test.member.service.UserService;
import com.test.model.User;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@RestController
@RequestMapping("/user/center")
public class UserCenterController {


    @Autowired
    private UserService umsMemberService;



    @GetMapping("/loadUmsMember")
        public CommonResult<User> loadUserByUsername(String username){
        User umsMember = umsMemberService.getByUsername(username);
        if(umsMember == null){
            return CommonResult.failed("会员不存在或者已经被禁用");
        }
        return CommonResult.success(umsMember);
    }

    @ApiOperation(value = "获取当前登陆用户id")
    @RequestMapping(value = "/getCurrentMemberId", method = RequestMethod.GET)
    @ResponseBody
    public CommonResult<Long> getCurrentMemberId(@RequestHeader("memberId") Long memberId){

        return CommonResult.success(memberId);
    }

}
